chars = "abcdefghi555555jklmn1poplinda123455"

new_char = chars.replace("5", "five", 1)
new_char_all = chars.replace("5", "five")
print(f"new_char=={new_char}\n,new_char_all={new_char_all}")


str = "123456789"
print(f"str={str},id={id(str)}")

new_str = str.replace("0", "a")
print(f"newstr={new_str}，id={id(new_str)}")


# 字符串的正则使用
# 导入re模块，用于正则表达式操作
import re

# 定义一个包含特定模式的文本
text = "The rain in Spain"

# 使用re.sub()将所有小写字母'a'替换为小写字母'o'
# r'a' 是正则表达式模式，'o' 是替换字符串，text 是原始字符串
new_text = re.sub(r"a", "o", text)

# 打印替换后的字符串
# 预期输出: The roin in Spoin
print(new_text)

test_reg_str = "1-22-333-4444-55555-aaa-bbb-cccc-7777"
reg_str = "(\d+)"
match = re.search(reg_str, text)

replace_str = re.sub(r"(\d+)", "@qq.com", test_reg_str, flags=re.IGNORECASE)


print(f"原字符串为={test_reg_str}\n替换字后的字符串为={replace_str}")


# 定义用户数据
user_data = {"name": "Alice", "order_id": "12345", "amount": "99.99"}
print(user_data.items())


my_set = {1, 2, 3, 4}
print(type(my_set))

for index, item in enumerate(my_set):
    print(f"index={index}===={item}")
